<extend name="Base/common"/>
<block name="header">
  <php>if(!is_weixin()){</php>
  {:hook('mobileTopNav',array('title'=>$meta_title))}
  <php>}else{</php>
  <header class="bar bar-nav"> <a href="{:U('/')}" class="logo"><img src="{:get_cover(C('WAP_LOGO'),'path')}" height="34" alt="{:C('WEB_SITE_TITLE')}"></a> <span class="nav-invite">客服：<a class="text-danger" href="TEL:{:C('WEB_SITE_TEL')}">{:C('WEB_SITE_TEL')}</a></span> </header>
  <php>}</php>
</block>
<block name="body"> 
  <!-- 商品图片幻灯 -->
  <notempty name="data.images_list">
    <div class="slider">
      <div class="slide-group">
        <volist name="data.images_list" id="vo">
          <div class="slide">
            <img src="{:get_cover($vo['id'],'path')}">
          </div>
        </volist>
      </div>
      <ol class="slider-indicators">
        <volist name="data.images_list" id="vo">
          <li></li>
        </volist>
      </ol>
    </div>
  <else/>
    <i class="icon"></i>
    <p class="tips">暂无图片</p>
  </notempty>
  
  <!-- 商品名称、价格、收藏 -->
  <div class="item-info">
    <h4 class="name">{$data.name}
      <notempty name="data.subname"><span class="subname text-danger">{$data.subname}</span></notempty>
    </h4>
    <!-- {//商品标签} -->
    <notempty name="label">
    <div class="preferential">
        <volist name="label" id="lab">
          <span class="text-danger">{$lab}</span>
        </volist>
    </div>
    </notempty>
    <!-- {//商品价格} -->
    <div class="price-box">
      <span class="text-danger">
        <span class="yen">&yen;</span><em class="price Z_spec_price">{$data.price}</em>
      </span>
      <del>市场价：<span class="yen">&yen;</span>{$data.mprice}</del>
      <span class="text-danger">
        <if condition="$vizprice eq 1"><br><span>直播市场价：&yen;</span><em>{$data.zprice}</em>
        &nbsp;&nbsp;&nbsp;&nbsp;<span class="yen">供应链底价：&yen;</span><em>{$data.zlprice}</em>
          <br><span>主播提成：&yen;</span><em>{$data.zbyprice}元</em></if>
      </span>
    </div>
    <!--{//加入分销}-->
    <!--分销商品价格-->
    <if condition="(C('SDP_PRICE_SHOW')==1) AND (!empty(SHOP_SECRET)) AND ($data.sdp gt 0) AND (CONTROLLER_NAME eq 'Item')">
    <div class="fenxiao">
     <div class="fenxiao-number">
      <p>每件返现：<span>&yen;<em>{$sdp_fee}</em></span>元</p>
     </div>
     <div class="fenxiao-button">
        <if condition="$is_can_secret eq 1">
          <a hrfe="javascript:;" class="Z_item_add" data-itemid="{$data.id}"><i class="icon icon-jiahao1"></i><span>加入分销</span></a>
        <else />
          <a hrfe="javascript:;" class="Z_item_delete" data-itemid="{$data.id}"><i class="icon icon-jianhao"></i><span>移除分销</span></a>
        </if>
     </div>
    </div>
    </if>
    <!--{//优惠信息}-->
    <if condition="$data.show_preferential eq true">
      <div class="preferential">
        <!-- {//老客户立减}-->
        <if condition="$data.fugou_dis_price gt 0"> <span>老客户立减 {$data.fugou_dis_price} 元</span> </if>
        <!-- {//第二件折扣} -->
        <notempty name="data.SecondPieces"> <span>{$data.SecondPieces.name}</span> </notempty>
        <!-- {//满减} -->
        <notempty name="data.manjian"><span>满{$data.manjian.m.0}减{$data.manjian.j.0}</span></notempty>
      </div>
    </if>
    <!-- {//加入收藏} -->
    <!-- <div class="fav-box"> <a href="javascript:;" id="Z_item_{$data.id}" data-id="{$data.id}" class="fav
      <eq name='data.is_fav' value='1'> has-fav </eq>Z_add_fav"><i class="icon
      <eq name='data.is_fav' value='1'>icon-like-fill<else/> icon-like </eq>"></i></a>
    </div> -->
    <!-- {//运费} -->
    <div> 由{$store['store_name']|default='平台'}发货并提供售后服务<br />
      <span class="delivery_free text-danger">
      <php>$a_pr = get_store_free_amount($data['store_id']);</php>
      <gt name="a_pr" value="0"> 满{$a_pr}元包邮
      <else/>
      {$data.id|get_store_item_freight}
      </gt>
      <notempty name="data.SecondPieces"> （限购2件） </notempty>
      </span> </div>
  </div>

  <!-- 赠品 -->
  <notempty name="data.send_item">
    <div class="send-item"> <span class="send-item-tip">
      <gt name="data.send_min_num" value="1"> 买{$data.send_min_num}件赠送
        <else/>
        赠品 </gt>
      </span>
      <volist name="data.send_item" id="vv"> <span class="send-item-span"><a href="{:U('/Item/detail?id='.$vv['id'])}"><img src="{:get_image_thumb($vv['item_info']['thumb'], 100, 100)}" title="{$vv.item_info.name} × {$vv.num}" alt="{$vv.item_info.name} × {$vv.num}"/></a></span> </volist>
    </div>
  </notempty>
  <input type="hidden" id="Z_item_id" name="item_id" value="{$data.id}">

  <!-- <input type="hidden" id="Z_item_stock" name="stock" value="{$data.stock}"> -->
  <!-- 第二件打折，限购2件 -->
  <notempty name="data.SecondPieces">
  <input type="hidden" id="Z_item_stock" value="2" />
  <else/>
  <input type="hidden" id="Z_item_stock" value="{$data.stock}" />
  </notempty>
  <input type="hidden" id="Z_item_image" name="item_image" value="{$data.cover_path}">
  <input type="hidden" id="Z_item_price" name="price" value="{$data['price']}">
  <input type="hidden" id="Z_item_spec" name="specifiction"  value="">
  <input type="hidden" id="Z_item_code" name="item_code" value="{$data.number}">
  <input type="hidden" id="Z_sdp_code" name="sdp_code" value="{$_GET['sdp_secret']}">


  <!-- 已购买数量和已收藏数量 -->
  <div class="item-count" id="Z_buy_box">
    <ul class="flex-box info">
      <if condition="C('IS_SHOW_BUYNUM')">
        <li> <i class="icon icon-cart-fill"></i><em>{$data['buynum']}人已购买</em> </li>
      </if>
      <li> <i class="icon icon-like-fill"></i><em>{$data['favnum']}人已收藏</em> </li>
    </ul>
  </div>


  <!-- 商品数量选择 -->

  <div class="item-num">
    <php>$quota_num = $data['quota_num'] > 0 ? $data['quota_num'] : $data['stock'];</php>
    <notempty name="data.property.property_specifiction">
      <a href="#Z_spec_info" id="Z_select_spec" class="btn btn-block btn-spec">选择：规格、数量<i class="icon icon-arrow-right"></i></a>
    <else/>
      <!-- 购买数量选择 -->
      <h4>选数量
        <notempty name="data.quota_num">
          <span class="quota-tip">（{$data.id|quota_text}限购
            <span class="text-danger Z_quota_num">{$data.quota_num}</span> 件）
          </span>
        </notempty>
      </h4>
      <div class="num" <notempty name="data.quota_num"> style="float:inherit;margin-bottom:10px;" </notempty> >
        <a href="javascript:;" class="minus disabled Z_quantity_act" data-option="minus"><i class="icon">&minus;</i></a>
        <input id="Z_item_quantity" type="number" value="1" pattern="[0-9]*" min="1" max="{:min($data['stock'], $quota_num)}" required>
        <a href="javascript:;" class="plus Z_quantity_act {$quota_num==1? 'disabled': ''}" data-option="plus"><i class="icon">&plus;</i></a>
        <em id="J_EmStock" class="tb-hidden">库存<i class="Z_spec_quantity">{$data.stock}</i>件</em>
      </div>
    </notempty>
  </div>

  <!--商品优惠券-->
  <section class="itemExtraInfo" style="margin-bottom:20px">
    <notempty name="coupons">
      <div class="entry-lq">
          <div class="box shop mui-flex">
            <div class="ic-box"></div>
            <i class="icon icon-youhuiquan"></i>
            <div class="ct cell">店铺优惠券</div>
          </div>
          <button class="lq">领 取</button>
      </div>
    </notempty>
      <gt name="data.credit" value="0">
      <div class="J_activity activitylist activity" style="margin-right:-10px;">
          <div class="activityEntry mui-flex align-center" style="border-bottom: #eee solid 1px;padding-bottom: 5px;">
              <div class="ic-box" style="margin-right:-10px;"><span>购买可得{$data.credit}积分</span></div>
          </div>
          <div class="dot"></div>
      </div>
      </gt>
  </section>

  <!-- 商品参数 -->
  <notempty name="data.property.property_attribute">
    <div class="item-param">
      <h4>商品参数</h4>
      <ul>
        <volist name="data.property.property_attribute" id="prp">
          <li>
            <notempty name="prp['info'][0]"><span>{$prp.cname}：</span></notempty>
            <notempty name="prp.info">
              <volist name="prp.info" id="val">
                <in name="prp.formtype" value="input,textarea"> {$val}
                  <else/>
                  <eq name="prp.formtype" value="color">
                    <notempty name="val.item_pic"> <img src="{$val.item_pic}" alt="{$val['option']}" title="{$val['option']}" class="item_pic" />
                      <else/>
                      <notempty name="val.pic"> <img src="__ROOT__{$val.pic|get_cover='path'}" alt="{$val['option']}" title="{$val['option']}" />
                        <else/>
                        <i style="background:{$val['color']}"></i> </notempty>
                    </notempty>
                  </eq>
                  <eq name="prp.formtype" value="image"> <img src="__ROOT__{$val.pic|get_cover='path'}" alt="{$val['option']}" title="{$val['option']}" /> </eq>
                  {$val['option']}&nbsp; </in>
              </volist>
            </notempty>
          </li>
        </volist>
      </ul>
    </div>
  </notempty>

  <!-- 商品详细信息 -->
  <div class="item-intro">
    <h4>商品详情</h4>
    <div class="images">{$data['intro']}</div>
  </div>

  <!-- 用户评价 -->
  <div class="item-comment">
    <h4>用户评价</h4>
    <div class="comment">
      <notempty name="data.comment">
      <ul>
        <volist name="data.comment" id="vo">
          <li>
            <div class="article"> <strong>
              <if condition="$vo['Member']"> {$vo.Member.nickname|get_hidden_mobile}
                <else />
                {$vo.nickname} </if>
              </strong> <small class="text-info">{$vo.create_time|time_format}</small>
              <div class="info"> {$vo.content}
                <notempty name="vo.reply">
                  <div class="reply">
                    <div class="avatar"> <img class="media-object pull-left img-circle" src="__IMG__/logo-avatar.png" width="50" onerror="this.src='__IMG__/thumbnail.png'"> </div>
                    <div class="info"> <strong>回复</strong> <small class="text-info">{$vo.reply.create_time|time_format}</small>
                      <p>{$vo.reply.content}</p>
                    </div>
                  </div>
                </notempty>
              </div>
            </div>
            <div class="avatar">
              <if condition="$vo['Member']"> <img src="<notempty name="vo.Member.avatar">{:get_image_thumb($vo['Member']['avatar'], 120, 120)}
                <else/>
                __IMG__/avatar-default.png
                </notempty>
                " width="50" />
                <else />
                <img src="<notempty name="vo.image">{:get_image_thumb(get_cover($vo['image'], 'path'), 120, 120)}
                <else/>
                __IMG__/avatar-default.png
                </notempty>
                " width="50"> </if>
            </div>
          </li>
        </volist>
      </ul>
      <else/>
      <p>暂时没有用户评价！</p>
      </notempty>
    </div>
  </div>

  <!-- 返回首页浮动层 -->
  <?php if( ($data['store_id']) AND ($lasturl == 0)) {?>
  <a href="/Store/index/store_id/<?php echo $data['store_id'].'.html';?>" class="item-home-fixed"><i class="icon icon-home"></i></a>
  <?php }else{  ?>
  <a href="/" class="item-home-fixed"><i class="icon icon-home"></i></a>
  <?php }  ?>

</block>

<!-- 商品规格选择 -->
<block name="extend">
  <!-- 放到底部防止content z-index导致遮罩遮挡的bug -->
  <div id="Z_spec_info" class="modal modal-spec">
    <header class="bar bar-nav"> <a class="pull-right" href="#Z_spec_info"><i class="icon icon-close"></i></a>
      <h1 class="title">选择规格和数量</h1>
    </header>
    <div class="content content-padded">
      <div class="select-info"> <span id="Z_selected_info" class="pull-left">请您选择规格</span> <span class="pull-right text-danger"> <span class="yen">&yen;</span> <em class="price Z_spec_price">{$data.price}</em> </span> </div>
      <notempty name="data.property.property_specifiction">
        <div class="pro-spc" id="Z_item_spc">
          <!-- 规格选择 -->
          <volist name="data.property.property_specifiction" id="spc" key="spc_key">
            <div class="spec-box">
              <h3>选{$spc.cname}</h3>
              <dl class="sku-box Z_sku_box">
                <notempty name="spc.info">
                  <dd>
                    <ul class="Z_spec_item <in name='spc.formtype' value='checkbox'>text</in> <in name="spc.formtype" value="color,image">
                      color
                      </in>
                      ">
                      <volist name="spc.info" id="val" mod="3">
                        <li title="{$val.option}" class="choose Z_sale_porp" data-key="{$spc_key}" data-code="{$val.code}" args="key[{$val['code']}]={$spc.cname}&val[{$val['code']}]={$val['option']}&code[{$spc_key}]={$val['code']}"> <a href="javascript:;">
                          <switch name="spc.formtype">
                            <case value="color">
                              <notempty name="val.item_pic"> <img src="__ROOT__{:get_image_thumb($val['item_pic'], 40, 40)}" alt="{$val.option}" title="{$val.option}" class="item_pic" onclick="javacript:item.switchPic(this.src);" />
                                <else/>
                                <notempty name="val.pic"> <img src="__ROOT__{$val.pic|get_cover='path'}" alt="{$val.option}" title="{$val.option}" />
                                  <else/>
                                  <i style="background:{$val.color}"></i> </notempty>
                              </notempty>
                            </case>
                            <case value="image"> <img src="__ROOT__{$val.pic|get_cover='path'}" alt="{$val.option}" title="{$val.option}" /> </case>
                            <default />
                            {$val.option} </switch>
                          <span class="triangle">已选中</span> </a> <span class="option">{$val.option}</span> </li>
                      </volist>
                    </ul>
                  </dd>
                </notempty>
              </dl>
            </div>
          </volist>
          <notempty name="data.quota_num">
            <div class="select-info"> <span class="pull-left"> 当前商品{$data.id|quota_text}限购 <span class="text-danger Z_quota_num">{$data.quota_num}</span> 件 </span> </div>
          </notempty>
          <!-- 数量选择 -->
          <div class="spec-box-num">
            <h3>选数量</h3>
            <div class="num"> <a href="javascript:;" class="minus disabled Z_quantity_act" data-option="minus"><i class="icon">&minus;</i></a>
              <input id="Z_item_quantity" type="number" value="1" pattern="[0-9]*" min="1" max="{:min($data['stock'], $quota_num)}" required>
              <a href="javascript:;" class="plus Z_quantity_act {$quota_num ==1 ? 'disabled' : ''}" data-option="plus"><i class="icon">&plus;</i></a> <em id="J_EmStock" class="tb-hidden">库存<i class="Z_spec_stock">{$data.stock}</i>件</em> </div>
          </div>
          <a id="Z_spec_submit" class="btn btn-block btn-positive">确定</a> <a href="#Z_spec_info" class="btn btn-block">取消</a> </div>
      </notempty>
    </div>
  </div>
</block>

<!-- 底部信息 -->
<block name="footer">
  <div class="bar bar-tab item-act J_footer" data-id="{$store['store_id']}">
    <php>$store_qq = store_qq($store['store_id']);</php>
    <if condition="$data['seckill']">
     <span class="inh">
        <notempty name="store_qq">
          <a <eq name="is_app" value="1"> href="javascript:items.awaken_qq({$store_qq});" <else />href="http://wpa.qq.com/msgrd?v=3&uin={$store_qq}&site=qq&menu=yes"</eq> class="btn btn-block btn-positive btn-tab">
            <i class="icon icon-qq"></i><small>联系</small>
          </a>
        <else />
          <a href="javascript:$.ui.confirm('亲！出了一点点小问题，请联系店主');" class="btn btn-block btn-positive btn-tab">
            <i class="icon icon-qq"></i><small>联系</small>
          </a>
        </notempty>
     </span>
     <span class="inh">
        <a href="{:U('Store/index',array('store_id'=>$store['store_id']))}" class="btn btn-block btn-positive btn-tab" ><i class="icon icon-home"></i><small>店铺</small></a>
     </span>
     <span class="pull-left text-center" style="width: auto">
        <span class="Z_seckill_time"><div class="btn btn-block btn-tab disabled">秒杀已结束</div></span>
     </span>
     <span class="pull-right">
        <a href="javascript:;" class="btn btn-block btn-positive btn-tab Z_seckill_btn disabled">立即购买</a>
     </span>
    <else />
      <gt name="data.stock" value="0">
       <span class="inh">
          <notempty name="store_qq">
          <a <eq name="is_app" value="1"> href="javascript:items.awaken_qq({$store_qq});" <else />href="http://wpa.qq.com/msgrd?v=3&uin={$store_qq}&site=qq&menu=yes"</eq> class="btn btn-block btn-positive btn-tab">
            <i class="icon icon-qq"></i><small>联系</small>
          </a>
        <else />
          <a href="javascript:$.ui.confirm('亲！出了一点点小问题，请联系店主');" class="btn btn-block btn-positive btn-tab">
            <i class="icon icon-qq"></i><small>联系</small>
          </a>
        </notempty>
       </span>
       <span class="inh"><a href="{:U('Store/index',array('store_id'=>$store['store_id']))}" class="btn btn-block btn-positive btn-tab" ><i class="icon icon-home"></i><small>店铺</small></a></span>
       <span class="inh">
        <a href="javascript:;" data-id="{$data.id}" id="Z_item_{$data.id}"  class="btn btn-block btn-positive btn-tab fav" >
          <eq name="data.is_fav" value="1">
            <i class="icon icon-like-fill"></i><small>已收藏</small>
          <else />
            <i class="icon icon-like"></i><small>收藏</small>
          </eq>
        </a>
       </span>
       <span class="pull-left"><a href="javascript:;" class="btn btn-block btn-positive btn-tab" id="Z_quick_buy">立即购买</a></span>
       <span class="pull-right"><a href="javascript:;" class="btn btn-block btn-negative btn-tab" id="Z_add2cart">加入购物车</a></span>
      <else/>
       <span class="inh">
        <notempty name="store_qq">
          <a <eq name="is_app" value="1"> href="javascript:items.awaken_qq({$store_qq});" <else />href="http://wpa.qq.com/msgrd?v=3&uin={$store_qq}&site=qq&menu=yes"</eq> class="btn btn-block btn-positive btn-tab">
            <i class="icon icon-qq"></i><small>联系</small>
          </a>
        <else />
          <a href="javascript:$.ui.confirm('亲！出了一点点小问题，请联系店主');" class="btn btn-block btn-positive btn-tab">
            <i class="icon icon-qq"></i><small>联系</small>
          </a>
        </notempty>
       </span>
       <span class="inh">
        <a href="{:U('Store/index',array('store_id'=>$store['store_id']))}" class="btn btn-block btn-positive btn-tab" ><i class="icon icon-home"></i><small>店铺</small></a>
       </span>
       <span class="inh">
        <a href="javascript:;" id="store_fav" class="btn btn-block btn-positive btn-tab" >
          <eq name="data.store_fav" value="1">
            <i class="icon icon-like-fill"></i><small>已收藏</small>
          <else />
            <i class="icon icon-like"></i><small>收藏</small>
          </eq>
        </a>
       </span>
       <span class="pull-left"><a href="javascript:;" class="btn btn-block btn-positive btn-tab disabled">卖光</a></span>
       <span class="pull-right"><a href="{:U('/Item/search')}" class="btn btn-block btn-tab">其它</a></span>
      </gt>
    </if>
    <a href="{:U('Cart/index')}" class="cart-fixed">
      <i class="icon icon-cart"></i>
      <em class="num {$user_count['cart_count'] > 0 ? '' :'hide'}" id="Z_global_cart_quantity">{$user_count['cart_count']|default=0}</em>
    </a>
  </div>

  <!--优惠券弹出层-->
  <div class="mui-cover show" id="s-activity-youhui-wrapper" style="display: none !important;">
    <div class="fixe-con">
      <div class="tax-part">
        <h3 class="tax-title">店铺优惠券</h3>
        <!--店铺优惠券循环start-->
        <notempty name="coupons">
          <volist name="coupons" id="voo">
            <div class="tax-box " style="background:#FDF6EF;  color:#f77c04; ">
              <div class="mui-flex">
                <div class="tax-main cell-8">
                  <div class="tb">
                    <div class="tc">
                      <div class="c-main "><i class="mui-price-rmb">￥</i><span class="rmb">{$voo.amount}</span></div>
                      <div class="c-sub">满{$voo.norm}使用</div>
                      <div class="c-sub">有效期 {$voo.expire_time|time_format}</div>
                    </div>
                  </div>
                </div>
                <div class="tax-split">
                  <div class="line" style="border-color:#FFCDCD;"></div>
                </div>
                <div class="tax-operator cell" ><div class="c-jf" data-id="{$voo.id}">立即领取</div></div>
              </div>
            </div>
          </volist>
        </notempty>
        <!--店铺优惠券end-->
      </div>
    </div>
    <button class="finish-btn">完成</button>
  </div>
  <div class="cover-normal" id="hidden-div" style="display:none"></div>
</block>

<block name="script">
  <script type="text/javascript">
    //规格组合对应的价格，数量值数组
    var spc_data_info = null;
    var items;
    <notempty name="data.property.spc_data">
      spc_data_info = '{$data.property.spc_data}';
    </notempty>
    seajs.use(['item', 'cart', 'wechat'], function(item, cart, wechat){
      let buy = '{$buy}';
      if(buy == '1'){
        //判断是否已经选齐规格
        item.buy();
      }
      items = item;
      if({$data.stock} > 0){
        item.init(spc_data_info, {:json_encode($data['seckill'])});
      }else{
        item.init(spc_data_info, null);
      }
      //分销商品
      item.selectItem();
      item.deleteSpdItem();
      //解决返回按钮引起的购物车数量不正确的问题
      cart.getCartCount();
      wechat.init();
       //直接输入数字判断
      $('#Z_item_quantity').on('blur',function(){
        var val = $(this).val();
        if(val < 0){
          $(this).val(1);
        }
      });

    });    
  </script> 
</block>
